//
//  InstructorAdvancedTableVc.m
//  Courses
//
//  Created by xxx on 15/1/14.
//  Copyright (c) 2015年 wtf. All rights reserved.
//

#import "InstructorAdvancedTableVc.h"
#import "Teacher.h"
#import "AdvancedCell.h"
#import "CoursedInstructorVc.h"
#import "AdvancedDetailsVc.h"

@implementation InstructorAdvancedTableVc

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AdvancedCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell)
    {
        cell = [[AdvancedCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    
    if (self.items.count > indexPath.row)
    {
        cell.course = self.items[indexPath.row];
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}

- (NSArray *)fetchedItems
{
    return [Teacher getAdvancedCoursesByTeacherId:_teacherId];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (self.items.count > indexPath.row)
    {
        AdvancedDetailsVc *vc = [[AdvancedDetailsVc alloc] init];
        vc.course = self.items[indexPath.row];
        [self.rootVc.navigationController pushViewController:vc animated:YES];
    }
}

@end
